package cn.ijero.waterfallflow.detial;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;

import androidx.appcompat.widget.Toolbar;

import com.bumptech.glide.Glide;

import cn.ijero.waterfallflow.BaseActivity;
import cn.ijero.waterfallflow.R;

public class DetailActivity extends BaseActivity {

    private static final String TAG = "DetailActivity";
    private static final String KEY_TITLE = "TITLE";
    private static final String KEY_URL = "URL";

    // Data
    private String title;
    private String url;
    // View
    private Toolbar toolbar;
    private ImageView imageView;

    public static void start(Context context, String title, String url) {
        Intent starter = new Intent(context, DetailActivity.class);
        starter.putExtra(KEY_TITLE, title);
        starter.putExtra(KEY_URL, url);
        context.startActivity(starter);
    }

    @Override
    protected int getContentLayoutId() {
        return R.layout.activity_detail;
    }

    @Override
    protected void initViewBefore(Bundle savedInstanceState) {
        title = getIntent().getStringExtra(KEY_TITLE);
        url = getIntent().getStringExtra(KEY_URL);
    }

    @Override
    protected void initView() {
        toolbar = findViewById(R.id.toolbar);
        imageView = findViewById(R.id.imageView);

        toolbar.setTitle(title);

        Glide.with(this)
                .load(url)
                .into(imageView);
    }

    @Override
    protected void initViewListener() {
        toolbar.setNavigationOnClickListener(v -> {
            finish();
        });
    }

    @Override
    protected void initObserver() {

    }

    @Override
    protected void initData() {

    }
}